package Control;

import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

import GUI.TestingStageGui;
import Entity.MsgPackage;
import GUI.ScreenManager;
import Entity.Failure_report;

public class TestingStageControl {
	
	private TestingStageGui test_stage_gui;
	private MsgPackage testMsg;
	private Failure_report fail_rep; 
	
	public TestingStageControl(){
		test_stage_gui= new  TestingStageGui();
		testMsg= new MsgPackage();
		fail_rep= new Failure_report(); 
	}

	public TestingStageGui getTextingGui() {
		return test_stage_gui;
	}

	public void reqANDstageEntered(String ReqNum){
		fail_rep.setReqID(Integer.parseInt(ReqNum));
	}
	
	public boolean testing_Submit_pressed() {
		String x,y;
        x =(String) test_stage_gui.getDecision().getSelectedItem();
		y= test_stage_gui.getTextArea_comm().getText();
		if(x==null||y==null)
		{
			JOptionPane.showMessageDialog(null, "Not all the fileds all the fill", "ERROR", JOptionPane.ERROR_MESSAGE);
	        return false;
		}
		fail_rep.setDecision(x = (String) test_stage_gui.getDecision().getSelectedItem());
		fail_rep.setComments(y= test_stage_gui.getTextArea_comm().getText());
		testMsg.setObject(fail_rep);
		testMsg.setOp_code(OP_CODE.TESTING_STAGE);
        ScreenManager.getConnection().accept(testMsg);
		JOptionPane.showMessageDialog(null, "The report send successfully", "", JOptionPane.INFORMATION_MESSAGE);

		return true;
	}
}